/*
runTime: 0.0176
fileTree:
 +---- page/createBriefing.js
 |  +---- cpt/LJSDefine.js
 |  +---- cpt/modDefineValue.js
 |  +---- form/cFormTitle.js
 |  |  +---- form/cFormTips.js
 |  |  |  +---- form/jqCore.js
 |  |  +---- form/formInputText.js
 |  |  |  +---- mod/getStrLength.js
 |  +---- form/cFormTextarea.js
 |  |  +---- form/formTextarea.js
 |  |  |  +---- mod/cCustCursor.js
 |  +---- cpt/uploadPic.js
 |  |  +---- mod/cPrompt.js
 |  |  |  +---- mod/modTemplate.js
 |  |  |  +---- mod/cAlert.js
 |  |  |  |  +---- mod/win.js
 |  +---- form/cFormUrl.js
 |  +---- form/cFormNum.js
*/
/**
 * Copyright (c) 2010 - 2012, Sina Inc. All rights reserved.
 * @fileoverview    创建专题
 * @author bowen liu
 * @email liubowen082@163.com
 * @version 1.0
 */

//引用配置文件
//$require('cpt.LJSDefine');
//$require('cpt.collectionTop');

/**
 * Copyright (c) 2010 - 2012, Sina Inc. All rights reserved.
 * @fileoverview Sina  合辑承载页包含epg信息部分
 * @author bowen liu | liubowen082@163.com
 * @version 1.1 | 2013-4-13
 * @example
 * 
 */
if(typeof(LJS)=='undefined'){
	var LJS = {}
}
LJS.define = (function(){
    /**
	 * @id STK.register
	 * @alias STK.register
	 * @param {String} String
	 * @param {Function} Function
	 * @return {Void}
	 */
    var define = function(ns, maker) {
        var path = ns.split('.');
        var curr = LJS;
        for (var i = 0, len = path.length; i < len; i += 1) {
            if (i == len - 1) {
                if (curr[path[i]] !== undefined) {
                    throw ns + 'has been register!!!';
                }
                curr[path[i]] = maker(LJS);
                return true;
            }
            if (curr[path[i]] === undefined) {
                curr[path[i]] = {};
            }
            curr = curr[path[i]];
        }
    };
    
    
    return define
    
    
    
})();

/**
 * Copyright (c) 2010 - 2012, Sina Inc. All rights reserved.
 * @fileoverview Sina  修改input默认值
 * @author bowen liu | liubowen082@163.com
 * @version 1.1 | 2013-4-13
 * @example
 * 
 */


LJS.define('cpt.modDefineValue',function(){
	$('[event_type="defineValue"]').on('focus',function(){
		if($.trim($(this).val())==$(this).attr('defineValue')){
			$(this).val('')
			}
		}).on('blur',function(){
			if($.trim($(this).val())==''){
				$(this).val($(this).attr('defineValue'))
			}
			
			})

});

/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  表单信息提示层
 * @author  bowen liu | bowenliu@sohu-inc.com
 * @version 1.0 | 2012-06-29
 * @example
 */
/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  表单信息提示层
 * @author  bowen liu | bowenliu@sohu-inc.com
 * @version 1.0 | 2012-06-29
 * @example
 */
/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  扩展jq包
 * @author  bowen liu | bowenliu@sohu-inc.com
 * @version 1.0 | 2012-07-11
 * @example
 */
LJS.define('form.jqCore',function(ljs) {
	$.extend({
            setStyle: function(_div, st, value){
                $.E(_div).style[st] = value;
            },
            addEvent: function(el,type,fun){
                $(el).on(type,function(){
                    fun()
                })
            },
            E: function(el){
                return document.getElementById(el) || el || '';
            },
            C: function(node){
                return document.createElement(node);
            },
            removeClassName: function(el, className){
                $(el).removeClass(className);
            },
            addClassName: function(el, className){
                $(el).addClass(className);
            },
            position: function(dom){
                var obj = {}
                var _obj = $(dom).offset();
                obj.t = _obj.top;
                obj.l = _obj.left;
                return obj
            },
            sizzle: function(dom, par){
                return $(dom, par).get();
            },
            foreach: function(arr, fun){
                $.each(arr, function(i, a){
                    fun(a, i);
                })
                
            },
            queryToJson: function(QS, isDecode){
                var _fdata   = function(data,isEncode){
                		data = data == null? '': data;
                		data = $.trim(data.toString());
                		if(isEncode){
                			return encodeURIComponent(data);
                		}else{
                			return data;
                		}
                	};
                var _Qlist = $.trim(QS).split("&");
                var _json = {};
                var _fData = function(data){
                    if (isDecode) {
                        return decodeURIComponent(data);
                    }
                    else {
                        return data;
                    }
                };
                for (var i = 0, len = _Qlist.length; i < len; i++) {
                    if (_Qlist[i]) {
                        _hsh = _Qlist[i].split("=");
                        _key = _hsh[0];
                        _value = _hsh[1];
                        
                        // 如果只有key没有value, 那么将全部丢入一个$nullName数组中
                        if (_hsh.length < 2) {
                            _value = _key;
                            _key = '$nullName';
                        }
                        // 如果缓存堆栈中没有这个数据
                        if (!_json[_key]) {
                            _json[_key] = _fData(_value);
                        }
                        // 如果堆栈中已经存在这个数据，则转换成数组存储
                        else {
                            if ($.isArray(_json[_key]) != true) {
                                _json[_key] = [_json[_key]];
                            }
                            _json[_key].push(_fData(_value));
                        }
                    }
                }
                return _json;
            },
            jsonToQuery: function(JSON, isEncode){
                var _Qstring = [];
                if (typeof JSON == "object") {
                    for (var k in JSON) {
                        if (JSON[k] instanceof Array) {
                            for (var i = 0, len = JSON[k].length; i < len; i++) {
                                _Qstring.push(k + "=" + _fdata(JSON[k][i], isEncode));
                            }
                        }
                        else {
                            if (typeof JSON[k] != 'function') {
                                _Qstring.push(k + "=" + _fdata(JSON[k], isEncode));
                            }
                        }
                    }
                }
                if (_Qstring.length) {
                    return _Qstring.join("&");
                }
                else {
                    return "";
                }
            },
			jsonToStr :(function () {
    /**
     * 字符串处理时需要转义的字符表
     * @private
     */
    var escapeMap = {
        "\b": '\\b',
        "\t": '\\t',
        "\n": '\\n',
        "\f": '\\f',
        "\r": '\\r',
        '"' : '\\"',
        "\\": '\\\\'
    };
    
    /**
     * 字符串序列化
     * @private
     */
    function encodeString(source) {
        if (/["\\\x00-\x1f]/.test(source)) {
            source = source.replace(
                /["\\\x00-\x1f]/g, 
                function (match) {
                    var c = escapeMap[match];
                    if (c) {
                        return c;
                    }
                    c = match.charCodeAt();
                    return "\\u00" 
                            + Math.floor(c / 16).toString(16) 
                            + (c % 16).toString(16);
                });
        }
        return '"' + source + '"';
    }
    
    /**
     * 数组序列化
     * @private
     */
    function encodeArray(source) {
        var result = ["["], 
            l = source.length,
            preComma, i, item;
            
        for (i = 0; i < l; i++) {
            item = source[i];
            
            switch (typeof item) {
            case "undefined":
            case "function":
            case "unknown":
                break;
            default:
                if(preComma) {
                    result.push(',');
                }
                result.push($.jsonToStr(item));
                preComma = 1;
            }
        }
        result.push("]");
        return result.join("");
    }
    
    /**
     * 处理日期序列化时的补零
     * @private
     */
    function pad(source) {
        return source < 10 ? '0' + source : source;
    }
    
    /**
     * 日期序列化
     * @private
     */
    function encodeDate(source){
        return '"' + source.getFullYear() + "-" 
                + pad(source.getMonth() + 1) + "-" 
                + pad(source.getDate()) + "T" 
                + pad(source.getHours()) + ":" 
                + pad(source.getMinutes()) + ":" 
                + pad(source.getSeconds()) + '"';
    }
    
    return function (value) {
        switch (typeof value) {
        case 'undefined':
            return 'undefined';
            
        case 'number':
            return isFinite(value) ? String(value) : "null";
            
        case 'string':
            return encodeString(value);
            
        case 'boolean':
            return String(value);
            
        default:
            if (value === null) {
                return 'null';
            } else if (value instanceof Array) {
                return encodeArray(value);
            } else if (value instanceof Date) {
                return encodeDate(value);
            } else {
                var result = ['{'],
                    encode = $.jsonToStr,
                    preComma,
                    item;
                    
                for (key in value) {
                    if (value.hasOwnProperty(key)) {
                        item = value[key];
                        switch (typeof item) {
                        case 'undefined':
                        case 'unknown':
                        case 'function':
                            break;
                        default:
                            if (preComma) {
                                result.push(',');
                            }
                            preComma = 1;
                            result.push(encode(key) + ':' + encode(item));
                        }
                    }
                }
                result.push('}');
                return result.join('');
            }
        }
    };
})()
        });
	
});
LJS.define('form.cFormTips',function(ljs){
    
   var tipMsg = function(opt){
        var that = this;
        if (!opt || !opt.el) 
            return false;
        // 您需要在这个标签附近弹出tip
        that.el = opt.el;
        // 偏移量修正对象
        that.posObj = opt.posObj ||
        {
            't': 0,
            'l': 0
        };
        // 默认tip的方向,上up、下down、左left、右right
        that.arrow = opt.arrow || 'down';
        // 提示层标签,等待create
        that.tipEle = '';
        that.init();
    };
    tipMsg.prototype = {
        init: function(){
            var that = this;
            $(window).on('resize', function(){
                if (that.tipEle) {
                    $.setStyle(that.tipEle, 'top', that.getPosition(that.arrow).t + 'px');
                    $.setStyle(that.tipEle, 'left', that.getPosition(that.arrow).l + 'px');
                }
            });
            // 随机id
            that.rand = 'tip' + Math.floor(new Date().getTime() * Math.random());
        },
        /**
         * 创建全局DIV标签
         * id为随机id
         */
        create: function(){
            var that = this;
            var _div = $.C('div');
            //$.addClassName(_div, 'sTV5_forms_tips');
            $.setStyle(_div, 'position', 'absolute');
            $.setStyle(_div, 'zIndex', 999);
            $.setStyle(_div, 'borderRadius', '2px 2px 2px 2px');
            $.setStyle(_div, 'boxShadow', '0 1px 2px rgba(0, 0, 0, 0.40)');
			$.setStyle(_div, 'fontSize', '12px');
            //$.setStyle(_div, 'paddingLeft', '21px');
			//$.addClassName(_div,'pro02_su')
            if (typeof document.all !== 'object') {
                $.setStyle(_div, 'opacity', 1);
            }
            $.setStyle(_div, 'display', 'none');
            _div.id = that.rand;
            document.body.appendChild(_div);
            that.tipEle = $.E(that.rand);
            //var _arrowDiv = $.sizzle('div', that.tipEle)[0];
            //$.setStyle(_arrowDiv, 'overflow', 'visible');
        },
        /**
         * 获得标签的全局位置
         * @param {String} arrow up || right || down || left
         * @return {Object}
         * {
         * 	t:'', // 距上
         * 	l:''  // 距左
         * }
         */
        getPosition: function(arrow){
            var that = this;
            arrow = arrow ? arrow : that.arrow;
            var _top = 0, _left = 0;
            switch (arrow) {
                case 'up':
                    _top = $.position(that.el).t - 8;
                    _left = $.position(that.el).l;
                    break;
                case 'right':
                    _top = $.position(that.el).t;
                    _left = $.position(that.el).l + that.el.offsetWidth + 8;
                    break;
                case 'down':
                    _top = $.position(that.el).t + that.el.offsetHeight + 3;
                    _left = $.position(that.el).l;
                    break;
                case 'left':
                    _top = $.position(that.el).t;
                    _left = $.position(that.el).l - that.el.offsetWidth - 8;
                    break;
                default:
                    _top = $.position(that.el).t;
                    _left = $.position(that.el).l + that.el.offsetWidth;
            }
            return {
                't': _top + that.posObj.t,
                'l': _left + that.posObj.l
            };
        },
        /**
         * 显示弹层
         * @param {Object} content 显示内容
         */
        show: function(content,isError, arrow){
            var that = this;
            if (!that.tipEle) 
                that.create();
            arrow = arrow ? arrow : that.arrow;
            if (!that.tipEle) 
                return false;
//            var _arrowDiv = $.sizzle('div', that.tipEle)[0] || that.tipEle;
//            var _contentEle = $.sizzle('span', that.tipEle)[0] || that.tipEle;
//            $.removeClassName(_arrowDiv, 'arrowTop');
//            $.removeClassName(_arrowDiv, 'arrowRight');
//            $.removeClassName(_arrowDiv, 'arrowDown');
//            $.removeClassName(_arrowDiv, 'arrowLeft');
//            switch (arrow) {
//                case 'up':
//                    $.addClassName(_arrowDiv, 'arrowBottom');
//                    break;
//                case 'right':
//                    $.addClassName(_arrowDiv, 'arrowLeft');
//                    break;
//                case 'down':
//                    $.addClassName(_arrowDiv, 'arrowTop');
//                    break;
//                case 'left':
//                    $.addClassName(_arrowDiv, 'arrowRight');
//                    break;
//                default:
//                    $.addClassName(_arrowDiv, 'arrowRight');
//            }
            that.tipEle.innerHTML = content;
            
            switch(isError){
                case  1:
                    $.addClassName(that.tipEle,'pro02');
                    $.removeClassName(that.tipEle,'correct')
                break;
                case  2:
                    $.addClassName(that.tipEle,'correct')
                    $.removeClassName(that.tipEle,'pro02')
                break;
                default : 
                    $.removeClassName(that.tipEle,'correct')
                    $.removeClassName(that.tipEle,'pro02')
                break;
            }
            $.setStyle(that.tipEle, 'top', that.getPosition(arrow).t + 'px');
            $.setStyle(that.tipEle, 'left', that.getPosition(arrow).l + 'px');
            $.setStyle(that.tipEle, 'zIndex', 99);
            $.setStyle(that.tipEle, 'display', '');
            if (typeof document.all !== 'object') {
              //  $.core.ani.tween(that.tipEle, 'opacity', 1, 0.6, 'easeOutQuint');
            }
        },
        // 隐藏弹层
        hide: function(){
            var that = this;
            if (!that.tipEle) 
                return false;
            if (typeof document.all !== 'object') {
//                $.core.ani.tween(that.tipEle, 'opacity', 0, 0.4, 'easeOutQuint', {
//                    end: function(){
//                        $.setStyle(that.tipEle, 'display', 'none');
//                        $.setStyle(that.tipEle, 'zIndex', 999);
//                        that.del();
//                    }
//                });
                $.setStyle(that.tipEle, 'display', 'none');
                $.setStyle(that.tipEle, 'zIndex', 99);
                that.del();
            } else {
                $.setStyle(that.tipEle, 'display', 'none');
                $.setStyle(that.tipEle, 'zIndex', 99);
                that.del();
            }
        },
        // 删除弹层
        del: function(){
            var that = this;
            if (!that.tipEle) 
                return false;
            that.tipEle.parentNode.removeChild(that.tipEle);
            that.tipEle = '';
        }
    };
    return tipMsg
});
/**
 * Copyright (c) 2011 - 2012,  Inc. All rights reserved.
 * @fileoverview   表单-inputText基础类(用于type=txt的input控件)
 * @author  bowen liu | liubowen082@163.com
 * @version 1.0 | 2013-04-13
 * @param
 * opt{
 * 	'el': '',       // input标签
 * 	'isMust': '',   // 是否必填
 * 	'isChange': '', // 是否实时检测
 * 	'value': ''		// 缺省值
 * }
 * @example
 * var a = new STK.module.form.formInputText(opt);
 */
/**
 * Copyright (c) 2011 - 2012,  Inc. All rights reserved.
 * @fileoverview Sohu  获得字符串长度（中文*2）
 * @author  bowen liu | bowenliuSohu@sohu-inc.com
 * @version 1.0 | 2012-07-05
 * @example
 */
LJS.define('mod.getStrLength',function(ljs) {
	return function(str){
		if (!str) {
			return 0;
		}
		var aMatch = str.match(/[^\x00-\xff]/g);
		return (str.length + (!aMatch ? 0 : aMatch.length));
	};
	
});
LJS.define('form.formInputText',function(ljs){
    var getStrLength = ljs.mod.getStrLength;
    var formInputText = function(opt){
        var that = this;
        if (!opt || !opt.el) 
            return false;
        // input标签
        that.el = opt.el;
        // 是否是必填项,默认不是必填(供外部重写)
        that.isMust = opt.isMust || 0;
        // 是否实时判断合法性,默认不开启
        that.isChange = opt.isChange || 0;
        // 缺省值
        that.value = opt.value || null;
        // 全局计时器
        that.timer = null;
        // 保留對父級的引用
        that.__super__ = that.prototype;
    };
    formInputText.prototype = {
        init: function(){
            var that = this;
            that.value !== null ? that.setValue(that.value) : '';
        },
        /**
         * 聚焦方法
         * @param {Object} opt 配置对象
         * opt{
         * 	callback:functon(valueLength){
         * 		// do something you want.
         * 	},
         * 	loop:function(valueLength){
         * 		// do something loop you want.
         * 		// need isChange === true
         * 	}
         * }
         */
        focus: function(opt){
            var that = this;
            $(that.el).on('focus',function(){
                opt && opt.callback ? opt.callback(that.getValueLength()) : '';
                opt && opt.loop && that.isChange ? that.change(true, opt.loop) : '';
            });
        },
        /**
         * 失焦方法
         * @param {Object} opt 配置对象
         * opt{
         * 	callback:functon(valueLength){
         * 		// do something you want.
         * 	}
         * }
         */
        blur: function(opt){
            var that = this;
             $(that.el).on('blur',function(){
                // 解除频发函数
                that.change(false);
                // 回调字数
                opt && opt.callback ? opt.callback(that.getValueLength()) : '';
                $(that).trigger('onBlur')
            });
            
        },
        /**
         * 全选方法
         * opt{
         * 	callback:functon(valueLength){
         * 		// do something you want.
         * 	},
         * 	loop:function(valueLength){
         * 		// do something loop you want.
         * 		// need isChange === true
         * 	}
         * }
         */
        select: function(opt){
            var that = this;
            $(that.el).on('select', function(){
                opt && opt.callback ? opt.callback(that.getValueLength()) : '';
                opt && opt.loop && that.isChange ? that.change(true, opt.loop) : '';
            });
        },
        /**
         * 读取input值
         * @return string 字符串
         */
        getValue: function(){
            var that = this;
            return $.trim(that.el.value);
        },
        /**
         * 写入input值
         * @param {String} value 写入的内容
         */
        setValue: function(value){
            var that = this;
            that.el.value = value;
        },
        /**
         * 读取input值长度
         * @return number 字符长度,一个汉字算两个字符
         */
        getValueLength: function(){
            var that = this;
            return getStrLength(that.getValue());
        },
        /**
         * 频发函数
         * @param {Boolean} bool true开启频发 || false关闭频发
         * @param {Object} callback 可选回调
         */
        change: function(bool, callback){
            var that = this;
            if (bool == true && callback) {
                that.timer = setInterval(function(){
                    callback(that.getValueLength());
                }, 200);
            }
            else {
                that.timer ? clearInterval(that.timer) : '';
            }
        },
        /**
         * 判断是否为空
         * @return Boolean true || false
         */
        isEmpty: function(){
            var that = this;
            return that.getValueLength() < 1;
        },
        /**
         * 置为禁用
         * @param {Boolean} bool true || false
         */
        setDisabled: function(bool){
            var that = this;
            bool ? that.el.disabled = 'disabled' : that.el.disabled = '';
        },
        /**
         * 读取input是否可读
         * @return boolean true || false
         */
        getReadOnly: function(){
            var that = this;
            return that.el.readOnly;
        },
        /**
         * 设置input是否可读
         * @param {Boolean} bool true || false
         */
        setReadOnly: function(bool){
            var that = this;
            that.el.readOnly = bool;
        },
        /**
         * 以下都为空方法,供外部重写
         */
        check: function(){
        
        },
        showTip: function(){
        
        },
        showError: function(){
        
        },
        hide: function(){
        
        }
    };
    return formInputText;
});


LJS.define('form.cFormTitle',function(ljs){

    var cFormTips = ljs.form.cFormTips;
    var formInputText = ljs.form.formInputText;
    var formTitleTpl = {
        tip: '最多不要超过20个汉字',
        error: '最多不要超过20个汉字'
    };
    
    
    function formTitle(opt){
        var that = this;
        if (!opt || !opt.el) 
            return false;
        that.el = opt.el;
		that.tipsEl = opt.tipsEl || opt.el;   // 要弹出的提示层位置
        that.require = opt.require || [];
        that.value = that.el.value || null;
        var formData = that.el.getAttribute('form_data');
        that.data = typeof formData === 'string' ? $.queryToJson(formData) : {};
        that.min = parseInt(that.data.min) || '';
        that.max = parseInt(that.data.max) || '';
        that.formTitleTpl = opt.formTitleTpl || formTitleTpl;
        // 是否实时判断合法性
        that.changeStore = parseInt(that.data.isChange) || 0;
        that.isChange = 0;
        that.state = false;
        that.arrow = opt.arrow;
        that.posObj = opt.posObj;
        that.isMust = parseInt(that.data.isMust) || 0;
        that.isChe = that.data.isChe || 0;
        that.init();
    }
    formTitle.prototype = new formInputText;
    formTitle.prototype.constructor = formInputText
    formTitle.prototype.init = function(){
        var that = this;
        that.value !== null ? that.setValue(that.value) : '';
        that.tip = new cFormTips({
            'el': that.tipsEl || that.el,
            'arrow' : that.arrow,
            'posObj' : that.posObj
        });
        $.foreach(that.require, function(a, i){
            switch (a) {
                case 'focus':
                    that.focus({
                        callback: function(txtLength){
                            that.state === true ? '' : that.showTip();
                        },
                        loop: function(txtLength){
                            that.check() ? that.hide() : that.showError();
                        }
                    });
                    break;
                case 'blur':
                    that.blur({
                        callback: function(){
                            that.setValue(that.integerNum(that.getValue()));
                            if (that.check()) {
                                that.isChange = 0;
                                that.showRight();
                                that.state = false;
                                that.setValue(that.getValue());
                            }
                            else {
                                that.showError();
                                $.addClassName(that.el, 'error');
                                that.isChange = that.changeStore;
                                that.state = true;
                            }
                        }
                    });
                    break;
                case 'select':
                    that.select({
                        callback: function(){
                        }
                    });
                    break;
                default:
                    return false;
            }
        });
    };
    
    /**
     * 检测title是否符合要求
     */
    formTitle.prototype.check = function(){
        var that = this;
        var txtLength = that.getValueLength();
        if(that.isChe){
            if(!that.checkChinese()){
                return false
            }
        };
		if(that.getValue()==that.el.getAttribute('definevalue')){
			return false
			}
		
        if (that.isMust) {
            that.min = that.data.min || 1;
            that.max = that.data.max || 10000;
            return txtLength <= that.max && txtLength >= that.min;
        }
        else 
            that.min = that.data.min || 0;
        that.max = that.data.max || 10000;
        return txtLength <= that.max && txtLength >= that.min;
        
    };
    formTitle.prototype.checkChinese = function(){
        var that = this;
        var value = that.getValue();
        if(/[^\u4E00-\u9FA5]/g.test(value)) return false
        return /^([\u4E00-\uFA29]|[\uE7C7-\uE7F3])*$/g.test(value)
        //return true
    };
    formTitle.prototype.integerNum = function(str){
        str = $.trim(str);
        return str;
    }
    // 显示提示层
    formTitle.prototype.showTip = function(txt){
        var that = this;
        that.tip.show(txt || that.formTitleTpl.tip);
    };
    // 隐藏提示层
    formTitle.prototype.hide = function(){
        var that = this;
        $.removeClassName(that.el, 'error');
        that.tip.hide();
    };
    // 显示错误提示层
    formTitle.prototype.showError = function(txt){
        var that = this;
        that.tip.show(txt || that.formTitleTpl.error,1);
        $.addClassName(that.el, 'error');
    };
    formTitle.prototype.showRight = function(txt){
     var that = this;
     that.tip.show(txt || '',2);
	 $.addClassName(that.el,'error');
    };
    /**
     * 设置form_datad 值
     * 	J2Q();
     */
    formTitle.prototype.J2Q = function(){
        var that = this;
        var opt = {
            'max': that.max || '',
            'min': that.min || '',
            'isChange': that.isChange || 0,
            'isMust': that.isMust || 0
        }
        that.data = $.jsonToQuery(opt);
        that.el.setAttribute('form_data', that.data);
    };
    return formTitle;
});

/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu   表单-textarea组件类
 * @author  bowen liu | bowenliu@sohu-inc.com
 * @version 1.0 | 2012-06-29
 * @param
 * opt{
 * 	'el': '',       // textarea标签
 * 	'require':['focus','blur']    // 需要绑定的事件
 * }
 * form_data="isMust=1&isChange=1&value=1&max=20&min=1"
 * @example
 * var a = formTextarea(opt);
 */
/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  表单-textarea
 * @author  bowen liu | bowenliu@sohu-inc.com
 * @version 1.0 | 2012-07-05
 * @param
 * opt{
 * 	'el': '',       // textarea标签
 * 	'isMust': '',   // 是否必填
 * 	'isChange': '', // 是否实时检测
 * 	'value': ''		// 缺省值
 * }
 * @example
 * var a = new STK.module.form.formTextarea(opt);
 */
/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  自定义光标方法集合
 * @author  bowen liu | bowenliu@sohu-inc.com
 * @version 1.0 | 2012-07-12
 * 包括以下静态方法
 * .cCustCursor.getCursorPosition(); // 获得光标位置
 * .cCustCursor.setCursorPosition(); // 设置光标位置
 * .cCustCursor.add();			   // 添加内容
 * .cCustCursor.del();			   // 删除内容
 * .cCustCursor.sel();               // 选中指定区域的内容
 */
LJS.define('mod.cCustCursor',function(ljs){

     var cCustCursor = {};
    /**
     * 获得光标位置
     * @param {Object} el 光标所在的dom
     * @return {Object} {
     * 	start:'',
     * 	end:''
     * }
     * IE下只能获得开始位置,结束位置与开始位置相同
     */
    cCustCursor.getCursorPosition = function(el){
        // IE和web-kit缺省光标位置在0;
        // FF缺省光标位置在el.value.length;
        // IE在选取内容时,光标记录的是起始位置;
        // FF和web-kit在选取内容时,光标记录的是靠左的位置;
        var _start = 0;
        var _end = el.value.length;
        var _ds = document.selection || '';
        if (document.selection) {
            /*
            var _range = _ds.createRange();
            var _storedRange = _range.duplicate();
            _storedRange.moveToElementText(el);
            _storedRange.setEndPoint("EndToEnd", _range);
            el.selectionStart = _storedRange.text.length - _range.text.length;
            el.selectionEnd = el.selectionStart + _range.text.length;
            _start = el.selectionStart;
            _end = el.selectionEnd;
            */
            _start = el.value.length;
            _end = el.value.length;
        } else if (el.selectionStart || el.selectionStart == "0") {
            _start = el.selectionStart;
            _end = el.selectionEnd;
        }
        return {
            'start': _start,
            'end': _end
        };
    };
    /**
     * 设置光标位置
     * @param {Object} el 光标所在的dom
     * @param {Number} pos
     */
    cCustCursor.setCursorPosition = function(el, pos){
        var that = this;
        that.sel(el, pos, pos);
    };
    /**
     * 添加内容
     * @param {Object} el 光标所在的dom
     * @param {String} content 添加内容
     * @param {String || Number} where 在哪嵌入
     * allBefore 最前 || before 光标前 || after 光标后 || allBehind 最后 || number 具体位置
     * @param {Object} range IE的选块
     */
    cCustCursor.add = function(el, content, where, range){
        var that = this;
        setTimeout(function(){
            el.focus();
            setTimeout(function(){ //ie6 focus bug fix
                var _value = el.value;
                if($.browser.msie && el.tagName=="INPUT"){
                    el.blur();
                }
                if(_value==''){
                    el.value = '';
                }
                var _start = that.getCursorPosition(el).start;
                var _end = that.getCursorPosition(el).end;
                var _stopPos = 0;
                var _preValue = el.value.substring(0, _start);
                var _nextValue = el.value.substring(_end, el.value.length);
                switch (where) {
                    case 'allBefore':
                        _preValue = '';
                        _nextValue = el.value;
                        _stopPos = 0;
                        break;
                    case 'before':
                        if (range) {
                            // IE如果有range选块,把range选块内容置为空
                            range.text = '';
                            _preValue = el.value.substring(0, that.getCursorPosition(el).start);
                            _nextValue = el.value.substring(that.getCursorPosition(el).start, el.value.length);
                        }
                        _stopPos = _preValue.length + content.length;
                        break;
                    case 'after':
                        if (range) {
                            // IE如果有range选块,把range选块内容置为空
                            range.text = '';
                            _preValue = el.value.substring(0, that.getCursorPosition(el).start);
                            _nextValue = el.value.substring(that.getCursorPosition(el).start, el.value.length);
                        }
                        _stopPos = _preValue.length;
                        break;
                    case 'allBehind':
                        _preValue = el.value;
                        _nextValue = '';
                        _stopPos = el.value.length + content.length;
                        break;
                    default:
                        if (where || where === 0) {
                            that.setCursorPosition(el, where);
                            _start = that.getCursorPosition(el).start;
                            _end = that.getCursorPosition(el).end;
                            _preValue = el.value.substring(0, _start);
                            _nextValue = el.value.substring(_start, el.value.length);
                            _stopPos = _preValue.length + content.length;
                        }
                }
                el.value = _preValue + content + _nextValue;
                that.setCursorPosition(el, _stopPos);
                el.focus();
            },10);
        },10)
    };
    /**
     * 删除光标前面或者后面的length个字符(一个汉字算1字符)
     * @param {Object} el
     * @param {Number} length
     */
    cCustCursor.del = function(el, length){
        var that = this;
        var _pos = that.getCursorPosition(el).start;
        var _value = el.value;
        if (length > 0) {
            el.value = _pos >= length ? _value.slice(0, Math.abs(_pos - length)) + _value.slice(_pos) : _value.slice(_pos);
        } else {
            el.value = _value.slice(0, _pos) + _value.slice(_pos - length);
        }
        that.setCursorPosition(el, _pos - (length < 0 ? 0 : length));
    };
    /**
     * 选中从start到end位置的内容
     * @param {Object} el 光标所在的dom
     * @param {Number} start 起始位置
     * @param {Number} end 结束
     */
    cCustCursor.sel = function(el, start, end){
        if (document.selection) {
            var _range = el.createTextRange();
            _range.moveEnd('character', -el.value.length);
            _range.moveEnd('character', end);
            _range.moveStart('character', start);
            _range.select();
        } else {
            el.setSelectionRange(start, end);
            el.focus();
        }
    };
    return cCustCursor
});
LJS.define('form.formTextarea',function(ljs){
    var cCustCursor = ljs.mod.cCustCursor;
    var getStrLength = ljs.mod.getStrLength;
    var formTextarea = function(opt){
        var that = this;
        if (!opt || !opt.el) 
            return false;
        // textarea标签
        that.el = opt.el;
        // 是否是必填项,默认不是必填(供外部重写)
        that.isMust = opt.isMust || 0;
        // 是否实时判断合法性,默认不开启(供外部重写)
        that.isChange = opt.isChange || 0;
        // 缺省值
        that.value = opt.value || null;
        // 全局计时器
        that.timer = null;
    };
    formTextarea.prototype = {
        init: function(){
            var that = this;
            that.value !== null ? that.setValue(that.value) : '';
        },
        /**
         * 聚焦方法
         * @param {Object} opt 配置对象
         * opt{
         * 	callback:functon(valueLength){
         * 		// do something you want.
         * 	},
         * 	loop:function(valueLength){
         * 		// do something loop you want.
         * 		// need isChange === true
         * 	}
         * }
         */
        focus: function(opt){
            var that = this;
            $.addEvent(that.el, 'focus', function(){
                opt && opt.callback ? opt.callback(that.getValueLength()) : '';
                opt && opt.loop && that.isChange ? that.change(true, opt.loop) : '';
            });
        },
        /**
         * 失焦方法
         * @param {Object} opt 配置对象
         * opt{
         * 	callback:functon(valueLength){
         * 		// do something you want.
         * 	}
         * }
         */
        blur: function(opt){
            var that = this;
            $.addEvent(that.el, 'blur', function(){
                // 解除频发函数
                that.change(false);
                // 回调字数
                opt && opt.callback ? opt.callback(that.getValueLength()) : '';
            });
        },
        /**
         * 全选方法
         * opt{
         * 	callback:functon(valueLength){
         * 		// do something you want.
         * 	},
         * 	loop:function(valueLength){
         * 		// do something loop you want.
         * 		// need isChange === true
         * 	}
         * }
         */
        select: function(opt){
            var that = this;
            $.addEvent(that.el, 'select', function(){
                opt && opt.callback ? opt.callback(that.getValueLength()) : '';
                opt && opt.loop && that.isChange ? that.change(true, opt.loop) : '';
            });
        },
        /**
         * 为IE获得选区
         * 将选取赋值给全局that.range
         */
        click: function(){
            var that = this;
            $.addEvent(that.el, 'click', function(){
                document.selection ? that.range = document.selection.createRange() : '';
            });
        },
        /**
         * 读取textarea值
         * @return string 字符串
         */
        getValue: function(){
            var that = this;
            return $.trim(that.el.value);
        },
        /**
         * 写入textarea值
         * @param {Object} value 写入的内容
         * @param {String} cursorPosition 写入位置
         * front 最前 || before 光标前 || after 光标后 || behind 最后
         */
        setValue: function(value, cursorPosition){
            var that = this;
            if (typeof cursorPosition === 'undefined') {
                that.el.value = value;
                return true;
            }
            
            cCustCursor.add(that.el, value, cursorPosition, that.range);
            delete (that.range);
        },
        /**
         * 读取input值长度
         * @return number 字符长度,一个汉字算两个字符
         */
        getValueLength: function(){
            var that = this;
            return getStrLength(that.getValue());
        },
        /**
         * 频发函数
         * @param {Boolean} bool true开启频发 || false关闭频发
         * @param {Object} callback 可选回调
         */
        change: function(bool,callback){
            var that = this;
            if (bool == true && callback) {
                that.timer = setInterval(function(){
                    callback(that.getValueLength());
                }, 200);
            } else {
                that.timer ? clearInterval(that.timer) : '';
            }
        },
        /**
         * 判断是否为空
         * @return boolean true || false
         */
        isEmpty: function(){
            var that = this;
            return that.getValueLength() < 1;
        },
        /**
         * 置为禁用
         * @param {Boolean} bool true || false
         */
        setDisabled: function(bool){
            var that = this;
            bool ? that.el.disabled = 'disabled' : that.el.disabled = '';
        },
        /**
         * 读取input是否可读
         * @return boolean true || false
         */
        getReadOnly: function(){
            var that = this;
            return that.el.readOnly;
        },
        /**
         * 设置input是否可读
         * @param {Boolean} bool true || false
         */
        setReadOnly: function(bool){
            var that = this;
            that.el.readOnly = bool;
        },
        /**
         * 以下都为空方法,供外部重写
         */
        check: function(){
        
        },
        showTip: function(){
        
        },
        showError: function(){
        
        },
        hide: function(){
        
        }
    };
    
    return formTextarea;
    
})

LJS.define('form.cFormTextarea',function(ljs){
/*
 *$Import('module.form.formTextarea');
$Import('cpt.tipMsg');
$Import('tpl.formTextareaTpl');
 */
    var cFormTips = ljs.form.cFormTips;
    var _formTextarea = ljs.form.formTextarea;
    var formTextareaTpl = {
        tip: '只支持纯文本',
        error: '只支持纯文本，最多不超过140个汉字'
    }
    var formTextarea = function(opt){
        var that = this;
        if (!opt || !opt.el) 
            return false;
        // textarea标签
        that.el = opt.el;
        // 解form_data序列获得全局属性对象
        var _formData = that.el.getAttribute('form_data');
        that.data = typeof _formData === 'string' ? $.queryToJson(_formData) : {};
        // 是否是必选项
        that.isMust = parseInt(that.data.isMust) || 0;
        // 是否实时判断合法性
        that.changeStore = parseInt(that.data.isChange) || 0;
        that.isChange = parseInt(that.data.isChange) || 0;
        // 缺省值
        that.value = that.data.value || null;
        // 最大输入字数
        that.max = typeof that.data.max === 'string' ? parseFloat(that.data.max) : '';
        // 最小输入字数
        that.min = typeof that.data.min === 'string' ? parseFloat(that.data.min) : '';
        // 默认需要绑定的事件
        that.require = opt.require || [];
        // 此控件是否处于报错状态
        that.state = false;
        that.tipEl = opt.tipEl || null;
        that.arrow = opt.arrow;
        that.posObj = opt.posObj;
        that.formTextareaTpl = opt.formTextareaTpl || formTextareaTpl;
        that.init();
    };
    // 继承formTextarea
    formTextarea.prototype = new _formTextarea;
    formTextarea.prototype.constructor = _formTextarea
    formTextarea.prototype.init = function(){
        var that = this;
        that.value !== null ? that.setValue(that.value) : '';
        that.tip = new cFormTips({
            'el': that.el,
            'arrow' : that.arrow,
            'posObj' : that.posObj
        });
        var _changeTip = function(){
            if (!that.tipEl) 
                return false;
            var _num = that.max - that.getValueLength();
            //_num < 0 ? $.addClassName(that.tipEl, that.tpl.tipClassName) : $.removeClassName(that.tipEl, that.tpl.tipClassName);
            that.tipEl.innerHTML = parseInt(_num/2);
            if(parseInt(_num/2)<0){
              $(that.tipEl).css('color','#F00');  
            }else{
                $(that.tipEl).css('color','');
            }
            
        };
        
        $.foreach(that.require, function(a){
            switch (a) {
                case 'focus':
                    that.isChange = that.changeStore;
                    that.focus({
                        callback: function(){
                            _changeTip();
                            that.state === true ? '' : that.showTip();
                        },
                        loop: function(){
                            _changeTip();
                            that.check() ? that.hide() : that.showError();
                        }
                    });
                    break;
                case 'blur':
                    that.blur({
                        callback: function(){
                            if (that.check()) {
                                that.isChange = 0;
                                that.showRight();
                                that.state = false;
                            } else {
                                that.showError();
								//$.addClassName(that.el, 'error');
                                that.isChange = that.changeStore;
                                that.state = true;
                            }
                        }
                    });
                    break;
                case 'click':
                    that.click();
                    break;
                default:
                    return false;
            }
        });
        _changeTip();
    };
    /**
     * 检测
     * @return Boolean true || false
     * 当为非必填项时,直接返回true
     */
    formTextarea.prototype.check = function(){
        var that = this;
        // 不是必选
        if (!that.isMust) 
            return true;
		if(that.getValue()==that.el.getAttribute('definevalue')){
			return false
			}
        // 必选
        // 没给最大值、最小值
        if (typeof that.max === 'string' && typeof that.min === 'string') 
            return true;
        // 空值
        if (that.isEmpty()) 
            return false;
        // 只给了最小值
        if (typeof that.max === 'string') 
            return that.getValueLength() >= that.min;
        // 只给了最大值
        if (typeof that.min === 'string') 
            return that.getValueLength() <= that.max;
        return that.getValueLength() >= that.min && that.getValueLength() <= that.max;
    };
    // 显示提示层
    formTextarea.prototype.showTip = function(){
        var that = this;
		$.removeClassName(that.el,'error');
        that.tip.show(that.formTextareaTpl.tip);
    };
    // 显示错误提示层
    formTextarea.prototype.showError = function(){
        var that = this;
		$.addClassName(that.el, 'error');
        that.tip.show(that.formTextareaTpl.error,1);
    };
    formTextarea.prototype.showRight = function(){
     var that = this;
     that.tip.show('',2);
	 $.addClassName(that.el,'error');
    };
    // 隐藏层
    formTextarea.prototype.hide = function(){
        var that = this;
		$.removeClassName(that.el, 'error');
        that.tip.hide();
    };
    /**
     * 更新html标签的form_data序列
     * 同时更新全局属性对象that.data
     */
    formTextarea.prototype.J2Q = function(){
        var that = this;
        var opt = {
            'value': that.value,
            'isMust': parseInt(that.isMust) || 0,
            'isChange': parseInt(that.data.isChange) || 0,
            'max': that.max,
            'min': that.min
        };
        that.data = $.jsonToQuery(opt);
        that.el.setAttribute('form_data', that.data);
    };
    
    return formTextarea;
});

/**
 * Copyright (c) 2010 - 2012, Sina Inc. All rights reserved.
 * @fileoverview Sina  新建案例里产品图片---上传
 * @author bowen liu | liubowen082@163.com
 * @version 1.1 | 2013-4-13
 * @example
 * {uploadBox // 容器名}
 */
/**
 * Copyright (c) 2012 - 2013,  Inc. All rights reserved.
 * @fileoverview   信息层-- 对话框
 * @author  bowen liu | liubowen082@163.com
 * @version 1.0 | 2013-04-13
 * @example
 */
/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  弹层包装类
 * @author  bowen liu | liubowen082@163.com
 * @version 1.0 | 2013-04-13
 * @param
 * @example
 * modTemplate('#{city||default:天津}欢迎你',{'city':'北京'}) === '北京欢迎你';
 */
LJS.define('mod.modTemplate',function(ljs){
	
	return function(template, data){
        return template.replace(/#\{(.+?)\}/ig, function(){
            var key = arguments[1].replace(/\s/ig, '');
            var ret = arguments[0];
            var list = key.split('||');
            for (var i = 0, len = list.length; i < len; i += 1) {
                if (/^default:.*$/.test(list[i])) {
                    ret = list[i].replace(/^default:/, '');
                    break;
                }
                else 
                    if (data[list[i]] !== undefined) {
                        ret = data[list[i]];
                        break;
                    }
            }
            return ret;
        });
    };
    
});

/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  信息层
 * @author  bowen liu | bowenliu@sohu-inc.com
 * @version 1.0 | 2012-06-29
 * @example
 */
/**
 * Copyright (c) 2011 - 2012, Sohu Inc. All rights reserved.
 * @fileoverview Sohu  弹出层
 * @author  bowen liu | liubowen082@163.com
 * @version 1.0 | 2013-04-13
 * @example
 */
LJS.define('mod.win',function(ljs){
    function stopBubble(e){
        if (e && e.stopPropagation) 
            e.stopPropagation()
        else 
            window.event.cancelBubble = true
    }
    var setXYCenter = function(obj, x, y){
		if (!obj) 
			return;
		x = x || 0;
		y = y || 0;
		obj.style.position = "absolute";
		obj.style.left = document.documentElement.offsetWidth / 2 - obj.offsetWidth / 2 + x + "px";
		var _scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
		var top = (Math.min(document.documentElement.clientHeight,$(document).height()) - obj.offsetHeight) * 0.5 + _scrollTop + y;
		top = top < 0 ? 0 : top;
		obj.style.top = top + "px";
		return obj;
	}
    var backbg = function(){
    }
    backbg.prototype = {
        show: function(){
            if (this.div) {
                this.div.show();
                return;
            }
            this.div = document.createElement('div');
            
            $(document.body).append(this.div);
            $(this.div).css({
                top: 0,
                left: 0,
                width: Math.max($(document.body).width(), 996),
                height: $(document.body).height(),
                position: 'absolute',
                'z-index': 998,
                background: '#000',
                opacity: 0.7
            });
			
            var t = this;
            $(window).on('resize', function(){
                $(t.div).css('width', Math.max($(document.body).width(), 996) + 'px');
                
            })
        },
        del: function(){
            if (this.div) {
                $(this.div).remove();
                return;
            }
        },
        hide: function(){
            if (this.div) {
                $(this.div).hide();
                return;
            }
        }
        
    }
    
    var win = function(op){
        this.tpl = op && op.tpl;
        this.showBg = op.showBg || false;
        if (this.showBg) 
            this.bg = new backbg();
        else {
            this.bg = {
                show: function(){
                },
                del: function(){
                },
                hide: function(){
                }
            }
        }
    }
    win.prototype = {
        show: function(op){
            this.tpl = this.tpl || op && op.tpl;
            if (this.win) {
                $(this.win).show();
                this.bg.show();
                $(this).trigger('onShow');
                return
            }
            var div = document.createElement('div');
            this.bg.show();
            $(div).html(this.tpl);
            $(document.body).append(div);
            $(div).css({
                // display: 'block',
                top: '50%',
                'z-index': 999,
                position: 'absolute',
                left: '50%'
            }).addClass('popBox clearfix');
            setXYCenter(div)
            
            $(window).scroll(function(){
                setXYCenter(div)
            });
            $(window).on('resize',function(){
                setXYCenter(div)
            })
            
            this.win = div;
            this.addEvent()
            $(this).trigger('onShow');
        },
        close: function(){
            if (this.win) {
                $(this.win).hide();
                this.bg.hide();
                $(this).trigger('onClose')
            }
        },
        del: function(){
            if (this.win) {
                $(this.win).remove();
                this.bg.del();
                $(this).trigger('onDel');
                this.win = null
            }
        },
        addEvent: function(){
            var t = this;
            $('[event_type=close]', this.win).on('click', function(e){
                e.preventDefault()
                t.close()
                stopBubble(e);
                return false;
            });
            $('[event_type=del]', this.win).on('click', function(e){
                t.del();
                stopBubble(e);
                return false
            });
        }
    }
    return win
});


LJS.define('mod.cAlert',function(ljs){

    var _temp = ljs.mod.modTemplate;
	var _layer = ljs.mod.win;
    /*//文本，是否自动关闭(false为自动关闭)  按钮   关闭时间  
     * {txt
     *  caClose
     *  btnTxt
     *  time}
     */
    var Alert = function(op){
        
        var opt = {
		    tpl : '<div class="inforPop">\
						<div class="title"><span class="btnExit"><a href="javascript:void(0);" event_type="del"></a></span></div>\
						<div class="txtGod"><span>#{txt}</span></div>\
					</div>',
            caClose : true,
            time : 2000,
            txt : '',
            btnTxt : '确定'
        }
        
        
        $.extend(opt,op)
        opt.tpl = _temp(opt.tpl,{
    			txt : opt.txt,
                btnTxt : opt.btnTxt
    		});
        
	    var _l = new _layer({
			tpl:opt.tpl
		});
        if(!opt.caClose){
            setTimeout(function(){
			_l.win && $(_l.win).hide("fast",function(){
				try{
					if(_l.win){
                    _l.del()
               }
				}catch(e){}
			});
		    },opt.time);
        }
		_l.show();
		return _l
    }
	return Alert
});
LJS.define('mod.cPrompt',function(ljs){
	var _layer = ljs.mod.cAlert;
    var _temp = ljs.mod.modTemplate;
    var _l = null
	function stopBubble(e){
        if (e && e.stopPropagation) 
            e.stopPropagation()
        else 
            window.event.cancelBubble = true
    }
    return function(op){
        
         var opt = {
			tpl : '<div class="infor inforNew inforJoin">\
					<div class="title"><span class="txt">信息提示</span><span class="btnExit"><a href="javascript:void(0)" event_type="del"></a></span></div>\
					<div class="fillList">\
						#{txt}\
					</div>\
					<div class="btnEn" style="padding-left:75px; padding-top:30px;"><a href="javascript:void(0)" event_type="ok" class="btn-et"><span>确定</span></a><a href="javascript:void(0);" event_type="del"" class="btn-ex"><span>取消</span></a></div>\
				</div>',
            caClose : true,
            time : 2000,
            txt : '',
            btnTxt : '确定',
            fun : function(){}
        }
        
        
        $.extend(opt,op)
        opt.tpl = _temp(opt.tpl,{
    			txt : opt.txt,
                btnTxt : opt.btnTxt
    	});
        
		
		if(_l){return _l}
		
		
	    _l = _layer(opt)
		
		$('[event_type="ok"]',_l.win).on('click',function(e){
			if($.isFunction(opt.fun)){
			 opt.fun();
			}
			stopBubble(e);
            return false;
		})
		
		$(_l).on('onDel',function(){
			_l = null
		})
		
		return _l
    }
	
});
LJS.define('cpt.uploadPic',function(ljs){
	var uploadPic = function(opt){
		this.box = $(opt.uploadBox)
		this.btn =$('[node_type=btn]' ,$(opt.uploadBox));
		this.iframId = 'upload'+new Date().getTime();
		this.form = $(opt.uploadForm)[0]?$(opt.uploadForm) : $('[node_type=form]' ,$(opt.uploadBox))
		this.file = $('[node_type=file]' ,this.form)
		this.init();
		}
    uploadPic.prototype = {
        
        init:function(){
            var that = this,_lay = null;
            $(this).on('uploadSuc',function(){
                that.btn.attr('isLoading','false');
            });
            $(this).on('uploadErr',function(){
                that.btn.attr('isLoading','false')
            })
            
            // 上传
            that.btn.on('click',function(){
				
                if(that.btn.attr('isLoading')=='true'){
	                    return
                }
                if(that.box.attr('isfulled')=='true'){
					ljs.mod.cAlert({txt:'图片数量超过限制，最多上传30张'})
					return
				}
				if(_lay){return}
				that.form[0].reset();
				if(!$.browser.mozilla){
					_lay = ljs.mod.cAlert({
						tpl : '<div class="infor inforNew inforJoin"><div class="title"><span class="txt">上传图片</span><span class="btnExit"><a event_type="del2" href="javascript:void(0)"></a></span></div>	<div class="fillList"></div>	<div style="padding-left:75px; padding-top:30px;" class="btnEn"></div></div>'
					})
					$('.fillList', _lay.win).append(that.form);
					
					that.form.show();
					
					$('[event_type="del2"]',_lay.win).on('click',function(){
						if(_lay){
							$(document.body).append(that.form);
							_lay.del();
							_lay = null;
						}
					})
					
				}else{
	                that.file.click();
				}
            })
            that.file.on('change',function(){
                that.btn.attr('isLoading','true');
                that.form.attr({
                    target: that.iframId
                   // action: './pbg_set.action?roomId=' + t.opt.roomId
                });
                that.upload();
				if(_lay){
					$(document.body).append(that.form)
					_lay.del();
					_lay = null;
				}
            })
            
        },
        upload: function(){
            var that = this;
            if ($('#'+that.iframId).length !== 0) 
            	return that.btn.attr('isLoading', 'true');
            if (!$('#'+that.iframId)[0]) {
                $(document.body).append('<iframe name="'+that.iframId+'" id="'+that.iframId+'" style="display:none"></iframe>');
				this.form.submit();
                $('#'+that.iframId).on('load', function(){
                    try {
                        var _val = $(this).contents().find('textarea').val();
                        _val = eval('(' + _val + ')');
                        if (!_val) {
                            return;
                        };
                                        } 
                    catch (e) {
                        setTimeout(function(){
                            $('#'+that.iframId).remove();
                        }, 100)
                        return;
                    }
                    
                    if (_val.status == '100000') {
                        // 成功
                        $(that).trigger('uploadSuc',_val)
                    }
                    else {
                        $(that).trigger('uploadErr',_val)
                    }
                    
                    setTimeout(function(){
                        $('#'+that.iframId).remove();
                    }, 200)
                    
                });
            }
            
        }
        
    }

    return uploadPic;
    




});

//$require('mod.uploadFlv');
/**
 * Copyright (c) 2011 - 2012,
 * @fileoverview Sina  表单-extUrl基础组件(用于type=url的input控件)
 * @author  bowenliu082 | bowenliu082@163.com
 * @version 1.0 | 2012-2-20
 * @param opt{
 * 	'el': '',       // input标签
 *  'require':['focus','blur']	//是否需要调用focus blur函数
 * }
 * form_data="isMust=1&isChange=1regPara=^abc$"
 * @example
 * var a = new STK.cpt.extend.extUrl(opt);
 */
LJS.define('form.cFormUrl', function(ljs){
    var extUrlTpl = {
		tip:'请正确填写url',
		error:'请正确填写url'
	}
    function extUrl(opt){
        var that = this;
        if (!opt || !opt.el) 
            return false;
        that.el = opt.el;
		that.tipsEl = opt.tipsEl || opt.el;   // 要弹出的提示层位置
        that.require = opt.require || [];
        that.value = that.el.value || null;
        var formData = that.el.getAttribute('form_data');
        that.data = typeof formData === 'string' ? $.queryToJson(formData) : {};
           // 是否实时判断合法性
        that.changeStore = parseInt(that.data.isChange) || 0;
        that.isChange = 0;
		that.state = false;
        that.isMust = parseInt(that.data.isMust) || 0;
        that.regPara = that.data.regPara || '';//要求传入的为正则表达式包括 '^'
        that.init();
    }
    extUrl.prototype = new ljs.form.formInputText;
    extUrl.prototype.init = function(){
        var that = this;
        that.value !== null ? that.setValue(that.value) : '';
		 that.tip = new ljs.form.cFormTips({
            'el': that.tipsEl || that.el
        });
        $.foreach(that.require, function(a, i){
            switch (a) {
                case 'focus':
                    that.focus({
                        callback: function(txtLength){
                           that.state === true ? '' : that.showTip();
                        },
                        loop: function(txtLength){
                           that.check() ? that.hide() : that.showError();
                        }
                    });
                    break;
                case 'blur':
                    that.blur({
                        callback: function(){
                            if (that.check()) {
                                that.isChange = 0;
                                that.hide();
                                that.state = false;
								that.setValue(that.getValue());
                            }
                            else {
                                that.showError();
								$.addClassName(that.el, 'error');
                                that.isChange = that.changeStore;
                                that.state = true;
                            }
                        }
                        
                        
                    });
                    break;
                default:
                    return false;
            }
        });
    };
    /**
     * 检测Url是否符合要求
     */
    extUrl.prototype.check = function(){
        var that = this;
        var urlValue = that.getValue();
        if (that.isMust) {
            if (that.isEmpty()) {
                return false;
            }
			if(that.getValue()==that.el.getAttribute('defValue')){
				return false
			}
            if (that.regPara) {
                var _reg = new RegExp(that.regPara, "ig");
                return _reg.test(urlValue);
            }
            var _regPara = /^(https|http|ftp|rtsp|mms):\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/i;
			//console.log(_regPara.test(urlValue))
            return _regPara.test(urlValue);
        }
        else {
			 if (that.isEmpty()) {
                return  true;
            }
            if (that.regPara) {
				var _reg = new RegExp(that.regPara, "ig");
				 return _reg.test(urlValue);
			}
            if (urlValue == 'http://') {
                return true;
            }
            
            var _regPara = /^(https|http|ftp|rtsp|mms):\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/i;
			
            return _regPara.test(urlValue);
        }
        
    };
    
    // 显示提示层
    extUrl.prototype.showTip = function(){
      var that = this;
      that.tip.show(extUrlTpl.tip);
    };
    // 隐藏提示层
    extUrl.prototype.hide = function(){
    	var that = this;
		$.removeClassName(that.el, 'error');
       that.tip.hide();
    };
    // 显示错误提示层
    extUrl.prototype.showError = function(){
     var that = this;
	 	$.addClassName(that.el, 'error');
	 	that.tip.show(extUrlTpl.error,1);
    };
    
    
    /**
     * 设置form_datad 值
     * 	J2Q();
     */
    extUrl.prototype.J2Q = function(){
        var that = this;
        var opt = {
        	'regPara':that.regPara||'',
            'isChange': that.isChange || '',
            'isMust': that.isMust || ''
        }
        that.data = $.jsonToQuery(opt);
        that.el.setAttribute('form_data', that.data);
    };
    return extUrl;
})

/**
 * Copyright (c) 2011 - 2012,  Inc. All rights reserved.
 * @fileoverview   表单--number
 * @author  bowen liu | bowenliu@sohu-inc.com
 * @version 1.0 | 2012-06-29
 * @param opt{
 * 	'el': '',       // input标签
 *  'require':['focus','blur']	//是否需要调用focus blur函数
 * }
 * form_data="isMust=1&isChange=1&minValue=0&maxValue=10000"
 * @example
 * var a = new STK.cpt.extend.formNum(opt);
 */
 
 
 
LJS.define('form.cFormNum',function(ljs){

    var cFormTips = ljs.form.cFormTips;
    var formInputText = ljs.form.formInputText;
    var formNumTpl  =  {
		tip:'请输入数字',
		error:'非法数值'
	}
    
    
     function formNum(opt){
        var that = this;
        if (!opt || !opt.el) 
            return false;
        that.el = opt.el;
        that.require = opt.require||[];
        that.value = that.el.value||null;
        that.formNumTpl = opt.formNumTpl || formNumTpl;
        var formData = that.el.getAttribute('form_data');
        that.data = typeof formData === 'string' ? $.queryToJson(formData) : {};
        that.minValue = parseFloat(that.data.minValue) || '';
        that.maxValue = parseFloat(that.data.maxValue) || '';
       // 是否实时判断合法性
        that.changeStore = parseInt(that.data.isChange) || 0;
        that.isChange = 0;
		that.state = false;
        that.isMust = parseInt(that.data.isMust) || 0;
		that.posObj = opt.posObj;
        that.init();
    }
    formNum.prototype = new formInputText;
    formNum.prototype.constructor = formInputText
    formNum.prototype.init = function(){
        var that = this;
		that.value !== null ? that.setValue(that.value) : '';
		that.tip = new cFormTips({
            'el': that.el,
			'posObj' : that.posObj
        });
        $.foreach(that.require, function(a, i){
            switch (a) {
                case 'focus':
                    that.focus({
                        callback: function(){
                          that.state === true ? '' : that.showTip();
                        },
                        loop: function(){
                           that.check() ? that.hide() : that.showError();
                        }
                    });
                    break;
                case 'blur':
                    that.blur({
                        callback: function(){
							that.setValue(that.integerNum(that.getValue()));
                            if (that.check()) {
                                that.isChange = 0;
                                that.showRight();
                                that.state = false;
                            }
                            else {
                                that.showError();
								//$.addClassName(that.el, 'error');
                                that.isChange = that.changeStore;
                                that.state = true;
                            }
                        }
                        
                        
                    });
                    break;
                case 'select':
                    that.select({
                        callback: function(){
                        }
                    });
                    break;
                default:
                    return false;
            }
        });
    };
    /**
     * 检测number是否符合要求
     */
    formNum.prototype.check = function(){
        var that = this;
        var numValue = that.getValue();
        if (that.isMust) {
			if (that.isEmpty()) return false;
			if (!that.regNumber(numValue)) //当输入的不合法时
				return false;
			if (numValue=== 0 && numValue>=that.minValue) return true;
			
			if (that.minValue && that.maxValue) {
				return numValue <= that.maxValue && numValue >= that.minValue;
			}
			if (that.minValue) {
				return numValue >= that.minValue;
			}
			if (that.maxValue) {
				return numValue <= that.maxValue;
			}
			return true;
		}
		else {
			if (that.isEmpty()) 
				return true;
			if (numValue === 0 && numValue>=that.minValue) 
				return true;
			if (!numValue) //当输入的为字母是 Number（'abc'）==NaN
				return false;
			if (that.minValue && that.maxValue) {
				return numValue <= that.maxValue && numValue >= that.minValue;
			}
			if (that.minValue) {
				return numValue >= that.minValue;
			}
			if (that.maxValue) {
				return numValue <= that.maxValue;
			}
			return true;
		}
        
    };
	//验证是否为整数
	 formNum.prototype.regNumber = function(str){
	 	var r =/^\d+$/;//正整数+0
 		return  r.test(str);
	 }
	// 去掉整数前面多余的0         
	 formNum.prototype.integerNum = function(str){
	 	str = str.replace(/\s/g,'');
         if (str.replace(/^0+/,'')!='' && str !== '') 
             return str.replace(/^0+/,'')
         return str;
	 }
	// 显示提示层
    formNum.prototype.showTip = function(){
      var that = this;
      that.tip.show(that.formNumTpl.tip);
    };
    // 隐藏提示层
    formNum.prototype.hide = function(){
      var that = this;
	  $.removeClassName(that.el,'error');
      that.tip.hide();
	  
    };
    // 显示错误提示层
    formNum.prototype.showError = function(){
     var that = this;
     that.tip.show(that.formNumTpl.error,1);
	 $.addClassName(that.el,'error');
    };
    // showRight
    formNum.prototype.showRight = function(){
     var that = this;
     that.tip.show('',2);
	 $.addClassName(that.el,'error');
    };
    /**
     * 设置form_datad 值
     * 	J2Q();
     */
    formNum.prototype.J2Q = function(){
        var that = this;
        var opt = {
            'maxValue':  that.maxValue || '', 
            'minValue':  that.minValue || '',
            'isChange': that.isChange || 0,
            'isMust': that.isMust || 0
        }
        that.data = $.jsonToQuery(opt);
        that.el.setAttribute('form_data', that.data);
    };
    return formNum;
});

LJS.define('page.createPro',function(ljs){
	
	var bries = $('[node_type="briefing"]'),titles=[],urls = [],biaoqians = [];
	window.uploads = [];
	
	$.each(bries,function(i,a){
					var upload = new ljs.cpt.uploadPic({
									   uploadBox : a
									   });
//					var upload = new ljs.mod.uploadFlv({
//						box:$(a),
//						objectName:'window.uploads['+i+']'
//					})
					$(upload).on('uploadSuc',function(evt,data){
								$('[node_type="imgId"]' ,a).val(data.content[0].id)
								$('[node_type="imgSrc"]',a).attr('src',data.content[0].url)
									  })
					$(upload).on('uploadErr',function(evt,data){
									ljs.mod.cAlert({txt:data.msg})			
								})
					uploads.push(upload);
					
					
					titles.push(new ljs.form.cFormTitle({
							'el': $('[node_type="title"]',a)[0],
							'arrow':'down',
							'require': ['focus', 'blur']
						}));
					biaoqians.push(new ljs.form.cFormNum({
						    'el': $('[node_type="biaoqian"]',a)[0],
							'arrow':'down',
							'require': ['focus', 'blur']
					}))
					urls.push(new ljs.form.cFormUrl({
							'el': $('[node_type="url"]',a)[0],
							'arrow':'down',
							'require': ['focus', 'blur']
						}));
					
						  
						  })

	
	$('#submitBtn').on('click',function(){
		var isError = false
						var idValues = [],titleValues=[],urlValues=[],biaoqianValue=[];
						$('#createError').hide();
						$.each($('[node_type="imgId"]'),function(i,a){
																 //console.log($(a).val()=='')
													//console.log($(a).val()==$(a).attr('defineValue'))			 
								if($(a).val()==''||$(a).val()==$(a).attr('defineValue')){
									isError = true
									return false
									}
								 idValues.push($(a).val())
								});
						if(isError){
							$('#createError').show();
							return
							}
						var errorTitles = null
						$.each(titles,function(i,a){
								if(!a.check()){
									isError = true;
									errorTitles = a;
									return false
									}
									
								titleValues.push(a.getValue())
								});
						if(isError){
							$('#createError').show();
							
							errorTitles.showError();
							return 
							}
						$.each(biaoqians,function(i,a){
								if(!a.check()){
									isError = true
									errorTitles = a;
									return false
									}
									
								biaoqianValue.push(a.getValue())
								});
						if(isError){
							$('#createError').show();
							errorTitles.showError();
							return 
							}
						$.each(urls,function(i,a){
								if(!a.check()){
									isError = true
									errorTitles = a;
									return false
									}
								urlValues.push(a.getValue())
								});
						if(isError){
							$('#createError').show();
							errorTitles.showError();
							return
							}
						$('#ids').val(idValues.join('####'));
						$('#titles').val(titleValues.join('####'));
						$('#urls').val(urlValues.join('####'));
						$('#biaoqians').val(biaoqianValue.join('####'))
						
						$('#postsForm').submit();
						
						})
	
})

